package com.lagou;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class JedisClientTest {
    public static void main2(String[] args) {
        Jedis jedis = new Jedis("192.168.18.131", 7001);
        jedis.set("jedis","helloworld");
        System.out.println(jedis.get("jedis"));
    }


    public static void main(String[] args) {
        JedisPoolConfig Config = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("192.168.18.132",7001));
        jedisClusterNode.add(new HostAndPort("192.168.18.132",7002));
        jedisClusterNode.add(new HostAndPort("192.168.18.132",7003));
        jedisClusterNode.add(new HostAndPort("192.168.18.132",7004));
        jedisClusterNode.add(new HostAndPort("192.168.18.132",7005));
        jedisClusterNode.add(new HostAndPort("192.168.18.132",7006));
        jedisClusterNode.add(new HostAndPort("192.168.18.132",7007));
        jedisClusterNode.add(new HostAndPort("192.168.18.132",7008));
        JedisCluster jcd = new JedisCluster(jedisClusterNode, Config);
        jcd.set("name:006","zhangsan");
        String value = jcd.get("name:006");
        System.out.println(value);
    }
}
